<template>
  <div>
    <div class="bg-white grid-content">
      <div>
        <el-form :inline="true" :model="yjbbForm" class="demo-form-inline">
          <el-form-item label="日期:">
            <el-date-picker
              v-model="searchDate"
              align="right"
              type="date"
              placeholder="请选择日期"
              :picker-options="pickerOptions"
            >
            </el-date-picker>
          </el-form-item>

          <!-- <el-form-item label="日期:">
            <el-date-picker v-model="searchDate" type="daterange" align="right" unlink-panels range-separator="至"
              start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary">查询</el-button>
            <el-button type="success">下载</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div style="overflow: hidden"></div>

      <el-tabs v-model="activeName" type="card" @tab-click="handleMenuClick">
        <el-tab-pane label="水井作业情况表" name="first">
          <el-select v-model="zyqvalue" placeholder="请选择作业区" style="margin-bottom: 20px" @change="userJumpChange">
            <el-option
              v-for="item in zyqOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          <el-table
            :data="tableData"
            border
            style="width: 100%"
            :header-cell-style="{ background: '#F5F7FA', color: '#909399' }"
            v-show="sjzyqkVisable"
          >
            <el-table-column type="index" align="center" label="序号"></el-table-column>
            <el-table-column align="center" prop="rq" label="填表日期">
            </el-table-column>
            <el-table-column align="center" prop="zyqmc" label="作业区名称">
            </el-table-column>
            <el-table-column prop="id" align="center" label="类型">
              <el-table-column align="center" prop="tbrq" label="重配井">
                <el-table-column align="center" prop="cpjjs" label="井数">
                </el-table-column>
                <el-table-column align="center" prop="cpjrpz" label="日配注">
                </el-table-column>
              </el-table-column>
              <el-table-column align="center" prop="aqscts" label="分层、细分井">
                <el-table-column align="center" prop="fpjs" label="井数">
                </el-table-column>
                <el-table-column align="center" prop="fprpz" label="日配注">
                </el-table-column>
              </el-table-column>
              <el-table-column align="center" prop="bbzbrqm" label="大修井">
                <el-table-column align="center" prop="dxjjs" label="井数">
                </el-table-column>
                <el-table-column align="center" prop="dxjrpz" label="日配注">
                </el-table-column>
              </el-table-column>
              <el-table-column align="center" prop="bbzbrqm" label="其他水井作业">
                <el-table-column align="center" prop="qtsjzyjs" label="井数">
                </el-table-column>
                <el-table-column align="center" prop="qtsjzyrpz" label="日配注">
                </el-table-column>
              </el-table-column>
            </el-table-column>
            <el-table-column align="center" prop="tbrq" label="已出方案未实施">
              <el-table-column align="center" prop="ycfawssjs" label="井数">
              </el-table-column>
              <el-table-column align="center" prop="ycfawssrpz" label="日配注">
              </el-table-column>
            </el-table-column>
            <el-table-column align="center" prop="aqscts" label="未出方案未实施">
              <el-table-column align="center" prop="wcfawssjs" label="井数">
              </el-table-column>
              <el-table-column align="center" prop="wcfawssrpz" label="日配注">
              </el-table-column>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="正在作业井" name="second">
          <el-select v-model="zyqvalue" placeholder="请选择作业区" style="margin-bottom: 20px" @change="userJumpChange">
            <el-option
              v-for="item in zyqOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          <el-table
            :data="tableData"
            border
            style="width: 100%"
            :header-cell-style="{ background: '#F5F7FA', color: '#909399' }"
            v-show="zzzyjVisable"
          >
            <el-table-column type="index" align="center" label="序号"></el-table-column>
            <el-table-column align="center" prop="rq" label="填表日期">
            </el-table-column>
            <el-table-column align="center" prop="zyqmc" label="作业区名称">
            </el-table-column>
            <el-table-column prop="xdmc" align="center" label="小队">
            </el-table-column>
            <el-table-column align="center" prop="jmc" label="井名称">
            </el-table-column>
            <el-table-column align="center" prop="sgrq" label="施工日期">
            </el-table-column>
            <el-table-column align="center" prop="ryx" label="日配注">
            </el-table-column>
            <el-table-column align="center" prop="sgcs" label="措施类型">
            </el-table-column>
            <el-table-column align="center" prop="sgjd" label="目前进度">
            </el-table-column>
            <el-table-column align="center" prop="bz" label="备注">
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="已出方案未实施" name="third">
          <el-select v-model="zyqvalue" placeholder="请选择作业区" style="margin-bottom: 20px" @change="userJumpChange">
            <el-option
              v-for="item in zyqOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          <el-table
            :data="tableData"
            border
            style="width: 100%"
            :header-cell-style="{ background: '#F5F7FA', color: '#909399' }"
            v-show="ycfawssVisable"
          >
            <el-table-column type="index" align="center" label="序号"></el-table-column>
            <el-table-column align="center" prop="rq" label="填表日期">
            </el-table-column>
            <el-table-column align="center" prop="zyqmc" label="作业区名称">
            </el-table-column>
            <el-table-column prop="xdmc" align="center" label="小队">
            </el-table-column>
            <el-table-column align="center" prop="jmc" label="井名称">
            </el-table-column>
            <el-table-column align="center" prop="sgrq" label="出方案日期">
            </el-table-column>
            <el-table-column align="center" prop="jyyy" label="措施原因">
            </el-table-column>
            <el-table-column align="center" prop="bz" label="备注">
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="未出方案未实施" name="fourth">
          <el-select v-model="zyqvalue" placeholder="请选择作业区" style="margin-bottom: 20px" @change="userJumpChange">
            <el-option
              v-for="item in zyqOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          <el-table
            :data="tableData"
            border
            style="width: 100%"
            :header-cell-style="{ background: '#F5F7FA', color: '#909399' }"
            v-show="wcfawssVisable"
          >
            <el-table-column type="index" align="center" label="序号"></el-table-column>
            <el-table-column align="center" prop="rq" label="填表日期">
            </el-table-column>
            <el-table-column align="center" prop="zyqmc" label="作业区名称">
            </el-table-column>
            <el-table-column prop="xdmc" align="center" label="小队">
            </el-table-column>
            <el-table-column align="center" prop="jmc" label="井名称">
            </el-table-column>
            <el-table-column align="center" prop="jyyy" label="措施原因">
            </el-table-column>
            <el-table-column align="center" prop="bz" label="备注">
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>

      <!-- 分页器 -->
      <el-pagination
        align="right"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNo"
        :page-sizes="[1, 5, 10, 20, 30]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import jyjclyxhzApi from "@/api/jyjclyxhz";

export default {
  data() {
    return {
      sjzyqkVisable:true,
      zzzyjVisable:false,
      ycfawssVisable:false,
      wcfawssVisable:false,
      activeName: "first",
      zyqOptions: [{
        value: '第一作业区',
        label: '第一作业区'
      }, {
        value: '第二作业区',
        label: '第二作业区'
      }, {
        value: '第三作业区',
        label: '第三作业区'
      },{
        value: '第四作业区',
        label: '第四作业区'
      },{
        value: '第五作业区',
        label: '第五作业区'
      },{
        value: '肇一',
        label: '肇一'
      },{
        value: '肇二',
        label: '肇二'
      },{
        value: '肇25',
        label: '肇25'
      },{
        value: '升22',
        label: '升22'
      }],
      //数据总条数
      total: 0,
      //当前页码
      pageNo: 1,
      // 分页数
      pageSize: 5,
      startDate: "",
      endDate: "",
      searchDate: "",
      zyqvalue:"第一作业区",
      // table数据
      tableData: [],
      //时间快捷选择
      pickerOptions: {
        // disabledDate(time) {
        //   return time.getTime() > Date.now();
        // },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        ],
      },

    };
  },
  created() {
    this.search();
    // this.reload();
    // //this.exportExcel();
  },
  methods: {
    async search() {
      this.tableData=[]
      var res=null
      if (this.activeName === "first") {
        res = await jyjclyxhzApi.getSjqkListByZyq(
          this.pageNo,
          this.pageSize,
          this.zyqvalue,
          this.searchDate[0],
          this.searchDate[1]
        );
        this.tableData = res.data.records;
      } else if (this.activeName === "second") {
        res = await jyjclyxhzApi.geSjByZtListByZyq(
          this.pageNo,
          this.pageSize,
          "正在作业井",
          this.zyqvalue,
          this.searchDate[0],
          this.searchDate[1]
        );
        this.tableData = res.data.records;
      } else if (this.activeName === "third") {
        res = await jyjclyxhzApi.geSjByZtListByZyq(
          this.pageNo,
          this.pageSize,
          "已出方案未实施",
          this.zyqvalue,
          this.searchDate[0],
          this.searchDate[1]
        );
        this.tableData = res.data.records;
      } else if (this.activeName === "fourth") {
        res = await jyjclyxhzApi.geSjByZtListByZyq(
          this.pageNo,
          this.pageSize,
          "未出方案未实施",
          this.zyqvalue,
          this.searchDate[0],
          this.searchDate[1]
        );
        this.tableData = res.data.records;
      }
      this.total = res.data.total;
      this.pageSize = res.data.size;
    },
    onSubmit() {
      console.log("submit!");
    },
    uploadData() {
      console.log("批量导入成功");
    },
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pageSize = val;
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
    // 序号计算
    indexMethod(index) {
      // index默认在0开始，这里+1
      return index + 1 + (this.currentPage - 1) * this.pageSize;
    },

    //Tab标签区域切换按钮事件
    handleMenuClick(tab, event) {
      var content = event.target.innerText;
      if (content === "水井作业情况表") {
        this.currentPageName = "水井作业情况表";
        this.sjzyqkVisable=true
        this.zzzyjVisable=false
        this.ycfawssVisable=false
        this.wcfawssVisable=false
      } else if (content === "正在作业井") {
        this.currentPageName = "正在作业井";
        this.sjzyqkVisable=false
        this.zzzyjVisable=true
        this.ycfawssVisable=false
        this.wcfawssVisable=false
      } else if (content === "已出方案未实施") {
        this.currentPageName = "已出方案未实施";
        this.sjzyqkVisable=false
        this.zzzyjVisable=false
        this.ycfawssVisable=true
        this.wcfawssVisable=false
      } else if (content === "未出方案未实施") {
        this.currentPageName = "未出方案未实施";
        this.sjzyqkVisable=false
        this.zzzyjVisable=false
        this.ycfawssVisable=false
        this.wcfawssVisable=true
      }
      console.log(this.currentPageName);
      this.search()
    },
    userJumpChange(){
      this.search()
    },
  },
};
</script>

<style lang="scss" scoped>
// 标题
.mytitle {
  font-size: large;
  padding-left: 10px;
  margin-bottom: 16px;
  float: left;
}

//按钮组
.myButtons {
  float: right;
}

//格子的样式
.bg-white {
  background: #ffffff;
}

.grid-content {
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.calendar ::v-deep .el-button-group::before {
  display: none;
}

.calendar ::v-deep .el-button-group::after {
  display: none;
}

// 分割线样式
.el-divider--horizontal {
  display: block;
  height: 2px;
  width: 100%;
  margin: 24px 0;
}

// 表单各项的样式
.el-form-item {
  margin: 15px 10px 15px 10px;
}
</style>
